<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>样式绑定</title>
  <script src="../js/vue.js"></script>
  <style>
    .basic {
      width: 200px;
      height: 200px;
      border: 1px solid pink;
      border-radius: 20px;
    }

    .a {
      background-color: red;
    }

    .b {
      background-color: green;
    }
  </style>
</head>

<body>
  <div id="root">
    <!-- 适用于样式类名不确认的情况 -->
    <div class="basic" :class="mood" @click="changeMood">
      {{name}}
    </div>
    <!-- 适用于样式类名,个数都不确认的情况 -->
    <div class="basic" :class="classArr">
      {{name}}
    </div>
    <!-- 适用于样式类名,个数都确认的情况 -->
    <div class="basic" :class="classObj">
      {{name}}
    </div>
      <!-- 适用于样式类名,个数都确认的情况 -->
      <div class="basic" :style="styleObj">
        {{name}}
      </div>
  </div>

</body>

<script type="text/javascript">
  Vue.config.productionTip = false;

  new Vue({
    el: '#root',
    data: {
      name: '尚硅谷',
      mood: 'a',
      classArr: ['a', 'b'],
      classObj: {
        a: true,
        b: true
      },
      styleObj: {
        fontSize: '50px',
      }
    },
    methods: {
      changeMood() {
        this.mood = 'b'
      }
    }
  })
</script>

</html>